/**
 * ComboxGrid 下拉grid
 */

Ext.define("app.components.ui.form.ComboGrid", {
    extend: "Ext.form.field.Picker",
    alias: "widget.combogrid_",
    xtype: "combogrid_",
    uses: [
        "app.components.ui.list.ComboGridPanel"
    ],
    config: {
        minPickerWidth: 300,
        store: null,//数据源
        displayField: null,//默认字段
        columns: null,//下来表格列
        maxPickerHeight: 300,//下拉框宽度
        minPickerHeight: 200,//下拉框高度
        valueLabel: "codeValue",//搜索栏代码lable
        nameLabel: "codeName",//搜索栏名称lable
    },
    editable: false,
    triggerCls: Ext.baseCSSPrefix + "form-arrow-trigger",
    initComponent: function () {
        var me = this;
        me.callParent();
        me.addEvents("select");
    },
    createPicker: function () {
        var me = this;
        var picker = new Ext.create("app.components.ui.list.ComboGridPanel", {
            store: me.store,
            floating: true,
            displayField: me.displayField,
            columns: me.columns,
            height: me.minPickerHeight,
            minWidth: me.minPickerWidth,
            codeValueLabel:me.valueLabel,
            codeNameLabel:me.nameLabel,
            shadow: true,
            listeners: {
                scope: me,
                itemdblclick: me.onItemDbClick
            },
        });
        return picker;
    },

    //双击行
    onItemDbClick: function (view, record) {
        this.selectItem(record);
    },


    selectItem: function (record) {
        var me = this;
        me.setValue(record.data.value);
        me.picker.hide();
        me.fireEvent("select", me, record)
    },

});

